#include "mylabel.h"
#include <QDebug>
#include <QMouseEvent>
MyLabel::MyLabel(QWidget*parent) : QLabel(parent){}

void MyLabel::enterEvent(QEnterEvent *)
{
    qDebug() << "enter event";
}

void MyLabel::leaveEvent(QEvent *)
{
    qDebug() << "leave event";
}

void MyLabel::mousePressEvent(QMouseEvent *event)
{
    // qt5的写法
    // QString str1 = QString("鼠标按下了 x = %1, y = %2").arg(event->x()).arg(event->y());
    // qDebug() << str1;
    // qt6的写法
    QPointF p = event->position();
    QString str = QStringLiteral("鼠标按下了 x = %1, y = %2")
                      .arg(p.x())
                      .arg(p.y());
    qDebug() << str;
}


